import { HintBtnView } from "../mapUI/HintBtnView";
import { LayerManager } from "../../manager/LayerManager";
import { EffectManager } from "../../manager/EffectManager";
import { SCrossMassacreChoose } from "../../../../Message/Public/SCrossMassacreChoose";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ClockManager } from "../../manager/ClockManager";
import { SCrossMassacreStart } from "../../../../Message/Public/SCrossMassacreStart";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { SecTimerView } from "../common/SecTimerView";
//class CrossMassacreHintBtn
    
    export  class CrossMassacreHintBtn extends HintBtnView
    {
        constructor()
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this.createChildren();
            this.addListeners();
            return;
        }

        public showEffect(arg1: Boolean): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1) 
            {
                loc1 = new Object /* flash.filters.GlowFilter */(268435302, 1, 6, 6, 4);
                loc2 = [loc1];
                EffectManager.glowFilterReg(this._crossMassacreBtn, loc2, 0.8, 10, 5, 0);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._crossMassacreBtn);
            }
            return;
        }

        public updateSelectCountDown(arg1: SCrossMassacreChoose): void
        {
            this._txtCountdown.setParse(HTMLUtil.addColor(Language.getString(80498), GlobalStyle.green));
            var loc1=arg1.endDt.time - ClockManager.instance.nowDate.time;
            loc1 = loc1 / 1000;
            if (loc1 <= 0) 
            {
                return;
            }
            this._txtCountdown.setLeftTime(loc1);
            return;
        }

        public updateEndCountDown(arg1: SCrossMassacreStart): void
        {
            this._txtCountdown.setParse(HTMLUtil.addColor(Language.getString(41818), GlobalStyle.green));
            var loc1=arg1.endDt.time - ClockManager.instance.nowDate.time;
            loc1 = loc1 / 1000;
            if (loc1 <= 0) 
            {
                return;
            }
            this._txtCountdown.setLeftTime(loc1);
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            super.dispose(arg1);
            if (this._crossMassacreBtn != null) 
            {
                this._crossMassacreBtn.dispose(arg1);
                this._crossMassacreBtn = null;
            }
            if (this._txtCountdown != null) 
            {
                this._txtCountdown.stop();
                this._txtCountdown.dispose(arg1);
                this._txtCountdown = null;
            }
            if (this._crossMassacreBtn != null) 
            {
                this._crossMassacreBtn.dispose(arg1);
                this._crossMassacreBtn = null;
            }
            return;
        }

        /* internal  */createChildren(): void
        {
            this._crossMassacreBtn = ObjCreate.createGLoadedButton(ResFileConst.CrossKillCityHintBtn, 0, 0, 60, 50, this);
            var loc1=GlobalStyle.textFormat1;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._txtCountdown = ObjCreate.createSecTimeView(HTMLUtil.addColor(Language.getString(80498), GlobalStyle.green), -40, 50, 146, 20, this, loc1);
            this._txtCountdown.filters = [FilterConst.glowFilter];
            this._txtCountdown.timeOutHandler = this.timerOutHandler;
            return;
        }

        /* internal  */timerOutHandler(): void
        {
            return;
        }

        /* internal  */addListeners(): void
        {
            this._crossMassacreBtn.configEventListener(flash.events.MouseEvent.CLICK, this.clickcrossMassacreHandler);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.addToStageHandler);
            return;
        }

        /* internal  */addToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            this.removeEventListener(flash.events.Event.ADDED_TO_STAGE, this.addToStageHandler);
            this.showEffect(true);
            return;
        }

        protected clickcrossMassacreHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.showEffect(false);
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossMassacreShowModule));
            return;
        }

        /* internal */ /* var */_crossMassacreBtn: GLoadedButton;

        /* internal */ /* var */_txtCountdown: SecTimerView;
    }
